<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@page import="com.framework.util.Const"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>充值</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="format-detection" content="telephone=no" />
    <jsp:include page="/jsp/inc_head.jsp"></jsp:include>
    <style>
        .cztop{
            border-bottom:1px solid #eee;
            padding:12px 3.5%;
            font-size:12px;
            color:#a7a7a7;
        }

        #zhezhao{
            background:#333;
            bottom: 0;
            width:100%;
            display: none;
            left: 0;
            opacity: 0.9;
            position: fixed;
            right: 0;
            top: 0;
            z-index: 1000;
        }
        .zzcltext{
            position: fixed;
            z-index: 1001;
            background: #fff;
            top: 30%;
            left: 50%;
            margin-left: -100px;
            width: 200px;
            height: 40px;
            text-align: center;
            border-radius: 10px;
            line-height: 40px;
        }
    </style>
</head>
<body>
<section class="am-g am-text-sm">
    <div class="am-u-sm-12 am-pad-none cztop">
        <div class="">
            充值金额
        </div>
        <div class="">
            <div class="rechargeNum"><span class="innerNum">50</span>元</div>
        </div>
    </div>
    <div class="am-u-sm-12 am-pad-none">
        <ul class="choseRecg">
            <li class="on"><span class="curNum">50</span>元</li>
            <li><span class="curNum">100</span>元</li>
            <li><span class="curNum">200</span>元</li>
            <li><span class="curNum">300</span>元</li>
            <li><span class="curNum">500</span>元</li>
            <li><span class="curNum">1000</span>元</li>
            <li><span class="curNum">2000</span>元</li>
            <li><span class="curNum">3000</span>元</li>
            <li><span class="curNum">5000</span>元</li>
        </ul>
        <div class="am-u-sm-12 am-pad-none oterNum">
            <div class="am-u-sm-3 am-pad-none metext">
                其他面额
            </div>
            <div class="am-u-sm-9 am-pad-none inNumDiv">
                <input id="chargeMoney" type="number" class="inputNum" value="" placeholder="请输入金额" />
                <span class="posiText">元</span>
            </div>
        </div>
    </div>
</section>

<!--footer-->
<a href="javascript:void(0);" onClick="submit();" class="botBtn sqtkCxsq" style="width: 640px;left: 50%; margin-left: -320px;">立即充值</a>

<div id="zhezhao">
    <div class="zzcltext">
        正在处理，请稍等。。。。
    </div>
</div>
<div class="am-modal am-modal-alert" tabindex="-1" id="myAlert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提示</div>
        <div class="am-modal-bd" id="myMsg">
            确定要去支付吗？
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" style="color:#999;" onclick="toOrder(1)">取消</span>
            <span class="am-modal-btn" style="color:#ff4c00" onclick="toOrder(2)">确定</span>
        </div>
    </div>
</div>
<script>
    $("ul.choseRecg li").click(function(){
        $('input.inputNum').val("");
        $("ul.choseRecg li").removeClass("on");
        $(this).addClass("on");
        var curVal = $(this).find("span.curNum").text();
        $(".innerNum").text(curVal);
    });
    $("input.inputNum").focus(function(){
        $("ul.choseRecg li").removeClass("on");
        $(".innerNum").html("输入金额");
    });
</script>

<script>
    var ajaxpath="${pageContext.request.contextPath}";
    $(function(){
        $('input.inputNum').on('input propertychange',function(){
            var result = $(this).val();
            console.log(result);
            $('.innerNum').html(result);
        });
    });

    function submit(){
        $("#zhezhao").css("display","block");//遮罩层
        var chargeMoney = $("#chargeMoney").val();
        if(chargeMoney==null||chargeMoney==''){
            $("#alert_message").html("请填写充值金额!");
            $("#my-alert").modal('open');
            return false;
        }
        doXinYePay(chargeMoney);
    }

    //兴业银行支付
    function doXinYePay(chargeMoney){

        $.ajax({
            url : ajaxpath + '/payBank/toPayBankOrderForCharge.do',
            type : "post",
            data : { attach : 2,chargeMoney:chargeMoney},
            dataType : "json",
            success : function(data) {
                if(data.result){
                    window.location.href ="https://pay.swiftpass.cn/pay/jspay?token_id="+data.msg+"&showwxtitle=1";
                }else{
                    if(data.msg='支付失败：扣除券点失败'){

                    }else{
                        alert(data.msg);
                        window.location.href = ajaxpath
                        + "/client_toClientCenter.do";
                    }

                }

            }
        });

    }
</script>
<script type="text/javascript">
    $(document).ready(function() {
        //敲击按键时触发
        $("input.inputNum").bind("keypress", function(event) {
            var event= event || window.event;
            var getValue = $(this).val();
            //控制第一个不能输入小数点"."
            if (getValue.length == 0 && event.which == 46) {
                // alert(1)
                event.preventDefault();
                $(".innerNum").html("输入金额");
                return;
            }
            //控制只能输入一个小数点"."
            if (getValue.indexOf('.') != -1 && event.which == 46) {
                event.preventDefault();
                //alert(1)
                return;
            }
            //控制只能输入的值
            if (event.which && (event.which < 48 || event.which > 57) && event.which != 8 && event.which != 46 ) {
                event.preventDefault();
                $(".innerNum").html("输入金额");
                return;
            }
        });
        //失去焦点是触发
        $("input.inputNum").bind("blur", function(event) {
            var value = $(this).val(), reg = /\.$/;
            if (reg.test(value)) {
                value = value.replace(reg, "");
                $(this).val(value);
            }
        });
    });
</script>
</body>
</html>